import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    loadingRef: 0,
    loginSysUserVo: {
      user_id: null,
      username: null,
      nickname: null,
      state: null,
      avatar: null,
      age: null,
      sex: null,
      pid: null,
      permissionCodes: []
    },
  },
  mutations: {
    incrementLoadingRef(state) {
      state.loadingRef++;
    },
    decrementLoadingRef(state) {
      if (state.loadingRef > 0) {
        state.loadingRef--;
      }
    },
    updateLoginSysUserVo(state, loginSysUserVo) {
      state.loginSysUserVo = loginSysUserVo;
    },
  },
  actions: {
    incrementLoadingRef({ commit }) {
      commit('incrementLoadingRef');
    },
    decrementLoadingRef({ commit }) {
      commit('decrementLoadingRef');
    },
    updateLoginSysUserVo({ commit }, loginSysUserVo) {
      commit('updateLoginSysUserVo', loginSysUserVo);
    },
  },
  modules: {},
});
